package iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Koizumi Sinya
 * @date 2018/04/02. 15:44
 * @edithor
 * @date
 */
public class ICustomIterator<T> implements MyIterator<T> {

    private List<T> list = new ArrayList<>();
    private int cursor = 0;

    public ICustomIterator(List<T> list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        return cursor != list.size();
    }

    @Override
    public T next() {
        T obj = null;
        if (this.hasNext()) {
            obj = list.get(cursor++);
        }
        return obj;
    }
}
